﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IZ.WebFileManager;
using System.Web.Security;

namespace BitPortal.Modules
{
    public partial class FileManager : System.Web.UI.UserControl
    {
        string parentID;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //if (Membership.GetUser() == null || !(Roles.IsUserInRole("Admin") || Roles.IsUserInRole("RootAdmin")))
                //{
                //    Response.Redirect("Login.aspx");
                //}
                if (!string.IsNullOrEmpty(Request.QueryString["Path"]))
                {
                    FileManager1.RootDirectories[0].DirectoryPath = Request.QueryString["Path"].ToString();
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileManager1.SelectedItems.Length == 0)
            {
                Literal1.Text = "<span> Bạn chưa chọn file! </span>";
            }
            else
            {
                parentID = Request.QueryString["parentID"].ToString();
                Literal1.Text = "";
                foreach (FileManagerItemInfo finfo in FileManager1.SelectedItems)
                {
                    Literal1.Text += "<a href=\"#\" onClick=\"window.opener.document.getElementById('" + parentID + "').value='" + finfo.VirtualPath + "';window.opener.document.getElementById('" + parentID + "').focus();window.close();\"> " + finfo.VirtualPath + " </a>";
                    Literal1.Text += "<br />";
                }
            }
        }

    }
}